home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4461 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  44 lines

  1. Path: mail2news.demon.co.uk!parkbayl.demon.co.uk
  2. From: Martin Bayly <martin@parkbayl.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Problem:  Passing pointer to function to Template Member function
  5. Date: Tue, 30 Jan 1996 13:11:14 GMT
  6. Organization: Park Bayly Ltd
  7. Message-ID: <391851586wnr@parkbayl.demon.co.uk>
  8. Reply-To: martin@parkbayl.demon.co.uk
  9. X-NNTP-Posting-Host: parkbayl.demon.co.uk
  10. X-Newsreader: Newswin Alpha 0.9
  11. X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!parkbayl.demon.co.uk
  12.  
  13. I have a parameterized list class.  I would like one of the list class member functions to iterate
  14. the list and for each object, call one of the object's own member functions.  Thus my class is 
  15. defined as:
  16.  
  17. template <class T>
  18. class List
  19. {
  20. public:
  21.     List( );
  22.     ~List( );
  23.     // other functions
  24. >    void Iterate(void (T::*pFunc)( ) );
  25. private:
  26.     Node<T> itsHead;
  27.     ULONG itsCount;
  28. };
  29.  
  30. i.e. I'm trying to define Iterate to take a pointer to a function of the object T, whatever T happens 
  31. to be.  I get the following two compile errors (Visual C++ V4.0):
  32.  
  33. error C2645: no qualified name for pointer to member (found ':: *')
  34. error C2629: unexpected 'void ('
  35.  
  36. Any help would be greatly appreciated.
  37.  
  38. -- 
  39. Martin Bayly
  40.  
  41. "I need a good blast!  Where's the wind?"
  42. --------------------------------------------------------
  43.  
  44.